﻿Public Class frmDetalleInventarioAgregar

  Private m_bNuevo As Boolean = False
  Private m_siCantidad As Int16 = 0
  Private m_vObsInv As String = String.Empty
  Private m_bSave As Boolean = False

  Public Property bNuevo() As Boolean
    Get
      Return m_bNuevo
    End Get
    Set(ByVal value As Boolean)
      m_bNuevo = value
    End Set
  End Property

  Public Property osiCantidad() As Int16
    Get
      Return m_siCantidad
    End Get
    Set(ByVal value As Int16)
      m_siCantidad = value
    End Set
  End Property

  Public Property ovObsInv() As String
    Get
      Return m_vObsInv
    End Get
    Set(ByVal value As String)
      m_vObsInv = value
    End Set
  End Property

  Public Property obSave() As Boolean
    Get
      Return m_bSave
    End Get
    Set(ByVal value As Boolean)
      m_bSave = value
    End Set
  End Property


  Private Sub frmDetalleInventarioAgregar_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
    nudsiCantidad.Focus()
  End Sub

  Private Function Validar() As Boolean
    If nudsiCantidad.Value = 0 Then
      MessageBox.Show("Por favor ingrese una cantidad.", g_sModulo, MessageBoxButtons.OK, MessageBoxIcon.Information)
      nudsiCantidad.Focus()
      Exit Function
    End If

    If txtvObsInv.Text.Trim.Length = 0 Then
      MessageBox.Show("Por favor ingrese una observación.", g_sModulo, MessageBoxButtons.OK, MessageBoxIcon.Information)
      txtvObsInv.Focus()
      Exit Function
    End If

    Return True
  End Function

  Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click
    Try
      If Validar() = False Then Exit Sub
      m_bSave = True
      m_siCantidad = nudsiCantidad.Value
      m_vObsInv = txtvObsInv.Text.Trim
      Me.Close()

    Catch ex As Exception
      MessageBox.Show(ex.Message, g_sModulo, MessageBoxButtons.OK, MessageBoxIcon.Error)
    Finally
      GC.Collect()
    End Try
  End Sub

  Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
    Me.Close()
  End Sub

End Class